#include "EPhController.h"

#include "eCPP.h"
namespace engine
{

//------------------------------------------------------------
EPhControllerDesc::EPhControllerDesc() :
m_vPosition( 0.f, 0.f, 0.f )
{

}

//------------------------------------------------------------
EPhCapsuleControllerDesc::EPhCapsuleControllerDesc() :
EPhControllerDesc(),
m_fHeight( 50.f ),
m_fRadius( 5.f )
{

}

//------------------------------------------------------------
const NxControllerDesc& EPhCapsuleControllerDesc::getNxControllerDesc() const
{
  m_NxCapsuleControllerDesc.position     = m_vPosition.getNxExtendedVec3();
  m_NxCapsuleControllerDesc.radius       = m_fRadius;
  m_NxCapsuleControllerDesc.height       = m_fHeight;
  m_NxCapsuleControllerDesc.upDirection  = NX_Y;

  return m_NxCapsuleControllerDesc;
}

//------------------------------------------------------------
EPhController::EPhController( NxController& controller )
{
  m_pNxController = &controller;
}

//------------------------------------------------------------
EVector EPhController::getPosition() const
{
  cASSERT( m_pNxController != NULL );
  return EVector( m_pNxController->getPosition() );
}

//------------------------------------------------------------
void EPhController::move(const engine::EVector &vDisplacement, 
                         _ePhCollisionGroup eCollisionGroup)
{
  cASSERT( m_pNxController != NULL );
  NxU32 uiCollisionFlags;
  m_pNxController->move(vDisplacement.getNxVec3(), eGET_NX_COLLISION_GROUP(eCollisionGroup), 0.000001f, uiCollisionFlags, 1.f );
}

} // end namespace